<!DOCTYPE html>
<!--

Mkup - DOM node builder

This is the Mkup workbench, a small tool that can be used to explore how Mkup works 
and to create code snippets.

Written as Part of Ostium, a product of agimatec GmbH <http://www.agimatec.de>

License:

The MIT License

Copyright (c) 2009 Sebastian Schuth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>Mkup Zen Workbench</title>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js" type="text/javascript" charset="utf8"></script>
	<script src="Mkup.js" type="text/javascript" charset="utf-8"></script>
	<script src="ZenMkup.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript" charset="utf-8"></script>
	<script>
		function init(){
			var 
				defaultSrc = ["div+div"], 
				helpBtn = $$('button.help').first();
			$('source').setValue(defaultSrc.join("\n"));
			$('example').update("");
			$('run').observe("click",onRunClick);
			helpBtn.observe("click", function(){
				$('helpText').toggle(); 
				helpBtn.update($('helpText').visible() ? "hide help":"show help");
				});
			$('helpText').hide();
			$('source').focus();
		}
		
		function onRunClick(){
			clearResults();
			try{
				eval('Mkup.zen($("results")).write("'+$F('source')+'");');
			} catch(e){
				alert(e);
			}
			$('html_results').update(getCreatedHTML().escapeHTML());
			fillExample();	
			prettyPrint();
			$('resultsHead').scrollIntoView();
		}
		
		function getCreatedHTML(){
			return $('results').innerHTML;
		}
		
		function addLineBreaksToHTML(html){
			return html;
		}
		
		function fillExample(){
			var ex = [];
			ex.push("Code:");
			ex.push("{{{");
			ex.push($F('source'));
			ex.push("}}}");
			ex.push("Result:");
			ex.push("{{{");
			ex.push(addLineBreaksToHTML(getCreatedHTML().escapeHTML()));
			ex.push("}}}");
			$('example').update(ex.join("\n"));
		}
		
		function clearResults(){
			$('results').innerHTML="";
		}
	</script>
	<link rel="stylesheet" href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" media="screen" title="no title" charset="utf-8">
	<style type="text/css" media="screen">
		body{
			background-color:gray;
		}
		h1{
			font: 14pt Futura,Arial;
		}
		#source{
			border:8px solid black;
			background-color:black;
			color:white;
			width:99%;
			font:10pt Monaco;
		}
		#results{
			border:1px solid black;
			width:100%;
			height:200px;
			background-color:white;
		}
		#html_results{
			border:1px solid black;
			width:100%;
			height:200px;
			background-color:#EEE;
		}
		#example{
			background-color:#EEE;
			/* this is only useful for documentation purposes, so turn it off for now*/
			display:none;
		}
		.scrolling{
			overflow-x:scroll;
			overflow-y:scroll;
		}
		#run{
			background-color:green;
			color:white;
			font: 15px Arial;
		}
		button.action{
			display:block;
			width:200px;
			height:40px;
			margin-left:auto;
			margin-right:0;
			margin-bottom:10px;
			margin-top:10px;
		}
		.help{
			float:right;
			clear:both;
			margin-top:5px;
		}
		
		#helpText{
			background-color:white;
			border: 1px solid green;
			padding:3px;
			margin-left:auto;
			margin-right:auto;
			margin-bottom:5px;
			width:70%;
		}
	</style>
</head>

<body onload="init();">
	<a class="help" target="_blank" href="http://code.google.com/p/mkup/wiki/ApiReference">API Reference (in new Window)</a>
	<button class="help">show help</button>
	<h1>Mkup Zen Workbench</h1>
	<div id="helpText">
		Type in the code you want to try into the upper test area and click "run" to see the results.
	</div>
	<input id="source"></textarea>
	<button id="run" class="action">run</button>
	<span id="resultsHead">Result:</span>
	<div id="results" class="scrolling"></div>
	Source:
	<pre class="prettyprint lang-html scrolling" id="html_results"></pre>
	<pre id="example" class="prettyprint lang-html scrolling"></pre>
</body>
</html>
